package main

import (
	"fmt"
	"ppa/init/config"
	"ppa/init/log"
	"ppa/init/mysql"
	"ppa/init/redis"
	"ppa/model"
	"ppa/routers"
	"ppa/routers/categories"
	"ppa/routers/collection"
	"ppa/routers/doc"
	"ppa/routers/nft"
	"ppa/routers/user"
)

func main() {
	//配置初始化
	resConfig := config.Init()
	//日志初始化
	log.Init(resConfig.Log)
	//mysql初始化
	mysql.Init(resConfig.Mysql)
	mysql.RegistTable(model.Nft{},model.User{},model.NftTransient{},model.Collection{},model.Categories{},model.CategoriesNft{})
	//redis初始化
	redis.Init(resConfig.Redis)
	//注册
	routers.Include(user.Routers,doc.Routers,collection.Routers,nft.Routers,categories.Routers)
	//初始化
	r := routers.Init()

	//启动
	if err := r.Run(":8899"); err != nil {
		fmt.Printf("startup service failed, err:%v\n\n", err)
	}
}

